/**
 * @author SilverBiology, LLC
 * @website http://code.google.com/p/gbif-spreadsheet-processor/
*/
Ext.namespace('GBIF');
Ext.namespace('GBIF.GeoSpatial')

GBIF.GeoSpatial.Georss = function(config){
	
	Ext.apply(this,config,{
				border: false
			,	tbar: [{
						xtype:'label'
					,	style:"padding:0px 5px"	
					,	text:this.txtGeorssFeed
				}, {
						xtype: 'textfield'  
					,	width: 350
					,	ref: '../url'
					,	vtype:'url'
					, enableKeyEvents: true 
					, listeners: {
							keypress:{
									scope:this
								,	fn: function( textfield, e ) {
										if (e.getKey() == e.ENTER) {
											this.loadGeoRSS();
										}
									}
							}
						}	
					},{
							text: this.txtLoad
						,	style: "padding:0px 5px"
						, scope: this
						,	handler: this.loadGeoRSS
					}
				]
			,	proxyUrl: "../resources/api/getcapabilities-proxy.php?url="
	});                     
		
	GBIF.GeoSpatial.Georss.superclass.constructor.call(this, config);
}

Ext.extend(GBIF.GeoSpatial.Georss,GBIF.GeoSpatial.MapComponent, {
	
	loadGeoRSS: function(){
		this.url.setValue(this.url.getValue().trim());
 		if(this.url.getValue()==''){
			GBIF.GeoSpatial.Notice.msg(this.txtError,this.txtUrlError);
		}else{
			if(this.url.isValid()){
				var urlValue = this.proxyUrl+this.url.getValue();
				var layerGeoRSS = new OpenLayers.Layer.GeoRSS("Fire", urlValue);
				this.map.addLayer(layerGeoRSS);	
			} else {
				GBIF.GeoSpatial.Notice.msg(this.txtError,"Please enter valid URL.");
			}
		}
	}

});